// pages/luanyeNet/luanyeNet.js
const app = getApp()
const {
  getConferenceById
} = require("../../utils/http/api")
const {
  imageUrl
} = require("../../utils/http/http").dev
const {
  getConferenceInfoList
} = require("../../utils/http/api")
const tool = require("../../utils/tool")

Page({

  /**
   * 页面的初始数据
   */
  data: {
    dataList:[],
    conferenceInfoId: '',
    conference: {},
    list: [
      {
      title: "“数字安全@数字中国”",
      picUrl: imageUrl + "/01.png",
      time: "2023",
      bind: "xihuMath"
    }, {
      title: "构建安全可信的数字世界",
      picUrl: imageUrl + "/02.png",
      time: "2022",
      bind: "xihuSafety"
    }, {
      title: "安全：数字化改革之根本",
      picUrl: imageUrl + "/03.png",
      time: "2021",
      bind: "xihuRevolution"
    }, {
      title: "数治安全 智理未来",
      picUrl: imageUrl + "/04.png",
      time: "2020",
      bind: "xihuFuture"
    }, {
      title: "安全：赋能数字新时代",
      picUrl: imageUrl + "/05.png",
      time: "2019",
      bind: "xihuEra"
    }, {
      title: "新时代 新安全 新力量",
      picUrl: imageUrl + "/06.png",
      time: "2018",
      bind: "xihuPower"
    }, {
      title: "智引新安全 数领大未来",
      picUrl:  imageUrl + "/07.png",
      time: "2017",
      bind: "xihuWisdom"
    }]
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    var _this = this
    _this.setData({
      conferenceInfoId: options.conferenceInfoId
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    var _this = this
    _this.getConferenceById()
    // _this.getConferenceInfoList()
  },
  getConferenceById() {  
    let _this = this;  
    getConferenceById(1).then((res) => {  
      console.log("关于大会", res);  
      if (res && res.data) {  // 确保res和res.data都存在  
        const conference = res.data;  
        _this.setData({  
          conference: conference,
        });
      }  
    }).catch((error) => {  
      console.error('请求活动详情失败:', error);  
    });  
  },
  // 获取大会基本信息
  getConferenceInfoList() {
    wx.showLoading({
      title: '加载中...',
    })
    let _this = this
    getConferenceInfoList().then(res => {
      if (res.rows.length > 0) {
        const dataList = res.rows
        console.log("大会基本信息", dataList)
        dataList.forEach(item => {
          item.conferenceDescriptionContent = tool.changeDetails(item.conferenceDescriptionContent, 15)
        })
        _this.setData({
          dataList
        })
        wx.hideLoading()
      }
    })
  },

  // 滑动距离
  onPageScroll: function (res) {
    // console.log(res,parseInt(res.scrollTop));
    this.setData({
      scrollTop: parseInt(res.scrollTop)
    })
  },
  scroll(e) {
    //console.log(e)
  },

  /**
   * 往期回顾
   */
  // 跳转2023
  xihuMath() {
    wx.navigateTo({
      url: '/pages/luanyeNet/xihuMath/xihuMath',
    })
  },
  // 跳转2022
  xihuSafety() {
    wx.navigateTo({
      url: '/pages/luanyeNet/xihuSafety/xihuSafety',
    })
  },
  // 跳转2021
  xihuRevolution() {
    wx.navigateTo({
      url: '/pages/luanyeNet/xihuRevolution/xihuRevolution',
    })
  },
  // 跳转2020
  xihuFuture() {
    wx.navigateTo({
      url: '/pages/luanyeNet/xihuFuture/xihuFuture',
    })
  },
  // 跳转2019
  xihuEra() {
    wx.navigateTo({
      url: '/pages/luanyeNet/xihuEra/xihuEra',
    })
  },
  // 跳转2018
  xihuPower() {
    wx.navigateTo({
      url: '/pages/luanyeNet/xihuPower/xihuPower',
    })
  },
  // 跳转2017
  xihuWisdom() {
    wx.navigateTo({
      url: '/pages/luanyeNet/xihuWisdom/xihuWisdom',
    })
  },
  // 跳转2016
  xihuStone() {
    wx.navigateTo({
      url: '/pages/luanyeNet/xihuStone/xihuStone',
    })
  },

  
  
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})